home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / Compiler / map.h < prev    next >
C/C++ Source or Header  |  1990-08-16  |  983b  |  55 lines

  1. /*
  2.  * @(#)map.h    1.2  3/18/87
  3.  */
  4. #ifndef map_h
  5. #define map_h
  6.  
  7. /*
  8.  * Maps are things that map one integer onto another.  There are
  9.  * create, insert, lookup, and destroy operations.
  10.  */
  11.  
  12. typedef struct TE {
  13.     int key;            /* the key for this entry */
  14.     int value;            /* what we want */
  15. } TE, *TEPtr;
  16.  
  17. typedef struct MapRecord {
  18.     TEPtr table;
  19.     int maxIndex, maxCount, count;
  20. } MapRecord, *Map;
  21.  
  22. #define NIL ((unsigned)0x80000000)
  23.  
  24. Map Map_Create();
  25.  
  26. Map Map_CreateSized(/* count */);
  27. /* int count */
  28.  
  29. void Map_Insert(/* map, key, value */);
  30. /* Map map; int key, value; */
  31.  
  32. int Map_Lookup(/* map, key */);
  33. /* Map map; int key; */
  34.  
  35. void Map_Delete(/* map, key */);
  36. /* Map map; int key; */
  37.  
  38. void Map_Destroy(/* map */);
  39. /* Map map; */
  40.  
  41. void Map_Print(/* map */);
  42. /* Map map; */
  43.  
  44. #define Map_For(m, key, value) \
  45.   { \
  46.     int index = 0; \
  47.     while (Map_FindNext((m), &index, (int *)&key, (int *)&value)) {
  48. #define Map_Next \
  49.     } \
  50.   }
  51.  
  52. #define Map_Count(m) ((m)->count)
  53.  
  54. #endif
  55.